package com.lkd.controller;

import com.lkd.dto.RegionDTO;
import com.lkd.entity.Region;
import com.lkd.result.TableInfo;
import com.lkd.service.RegionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
/**
 * @Author: Z.lx
 * @Date: 2025/8/17 13:24
 * @Description:
 **/
@RestController
@RequestMapping("/api/vm-service/region")
@Slf4j
public class RegionController {
    private final RegionService regionService;
    public RegionController(RegionService regionService) {
        this.regionService = regionService;
    }
    /**
    * @Description 列表搜索
    * @Param [regionDTO]
    * @Date 2025/8/17 13:26
    **/
    @GetMapping("/search")
    public TableInfo<Region> list(RegionDTO regionDTO){
        log.info("列表搜索:{}",regionDTO);
        return regionService.list(regionDTO);
    }
    /**
     * 新增区域信息
     */
    @PostMapping
    public boolean save(@RequestBody RegionDTO regionDTO){
        log.info("新增区域：{}",regionDTO);
        return regionService.save(regionDTO);
    }

    /**
     * @Description 更新区域
     * @Param [skuId]
     * @Date 2025/8/17 10:36
     **/
    @PutMapping ("/{regionId}")
    public boolean update(@PathVariable String regionId,@RequestBody RegionDTO regionDTO){
        log.info("更新区域:{},{}",regionId,regionDTO);
        regionDTO.setId(regionId);
        return regionService.update(regionDTO);
    }
    /**
     * @Description 查看区域详情
     * @Param [skuId]
     * @Date 2025/8/17 10:36
     **/
    /*@GetMapping("/{regionId}")
    public RegionVO region(@PathVariable("regionId") String regionId){
        return regionService.getRegion(regionId);
    }*/
    /**
     * @Description 删除区域
     * @Param [classId]
     * @Date 2025/8/15 20:57
     **/
    @DeleteMapping("/{regionId}")
    public boolean delete(@PathVariable String regionId){
        log.info("删除区域:{}",regionId);
        return regionService.delete(regionId);
    }
}
